<?php

use think\facade\Route;
use think\facade\Request;

$version = Request::header('version', 'v2');#接口版本
Route::group('', function () use ($version) {
    /**
     * 登录
     */
    Route::group('site', function () use ($version) {
        Route::post('login', "api/{$version}.Site/login");
        Route::post('loginOut', "api/{$version}.Site/loginOut");
    });

    Route::group('pro', function () use ($version) {
        Route::post('get-info', "api/{$version}.pro/getinfo");
    })->middleware('checkLogin');

    //单元管理
    Route::group('Unit', function () use ($version) {
        Route::get('index', "api/{$version}.Unit/index");
//        Route::get('process', "api/{$version}.Unit/process");
    })->middleware('checkLogin');

    //单词认读信息
    Route::group('WordRead', function () use ($version) {
        Route::get('index', "api/{$version}.WordRead/index");
    })->middleware('checkLogin');

    //短句认读信息
    Route::group('SentRead', function () use ($version) {
        Route::get('index', "api/{$version}.SentRead/index");
    })->middleware('checkLogin');

    //词组拼写
    Route::group('GroupSpell', function () use ($version) {
        Route::get('index', "api/{$version}.GroupSpell/index");
    })->middleware('checkLogin');

    //词组认读测试
//    Route::group('GroupExam', function () use ($version) {
//        Route::get('index', "api/{$version}.GroupExam/index");
//    })->middleware('checkLogin');

    //短句认读测试
//    Route::group('SentExam', function () use ($version) {
//        Route::get('index', "api/{$version}.SentExam/index");
//    })->middleware('checkLogin');

    /**
     * 会员管理
     */
    Route::group('member', function () use ($version) {
        Route::get('get-info', "api/{$version}.Member/getInfo");
    })->middleware('checkLogin');

    //学习中心
    Route::group('index', function () use ($version) {
        Route::get('index', "api/{$version}.Index/index");
        //点击标记
        Route::get('sign', "api/{$version}.Index/sign");
    })->middleware('checkLogin');

    //记录题
    Route::group('log', function () use ($version) {
        Route::get('index', "api/{$version}.Log/index");
    })->middleware('checkLogin');

    //在线评测
    Route::group('Beta', function () use ($version) {
        Route::get('index', "api/{$version}.Beta/index");
    })->middleware('checkLogin');

    //词组认读
    Route::group('GroupRead', function () use ($version) {
        Route::get('index', "api/{$version}.GroupRead/index");
    })->middleware('checkLogin');

    //测试
    Route::group('WordExam', function () use ($version) {
        Route::get('index', "api/{$version}.WordExam/index");
    })->middleware('checkLogin');

    //单词认读拼写
    Route::group('WordSpell', function () use ($version) {
        Route::get('index', "api/{$version}.WordSpell/index");
    })->middleware('checkLogin');

    //短句认读拼写
    Route::group('SendSpell', function () use ($version) {
        Route::get('index', "api/{$version}.SendSpell/index");
    })->middleware('checkLogin');

    // 错题本
    Route::group('errorLog', function () use ($version) {
        Route::get('index', "api/{$version}.errorLog/index");
    })->middleware('checkLogin');

    //错题记录
    Route::group('Error', function () use ($version) {
        //做错的
        Route::get('mistake', "api/{$version}.Error/mistake");
    })->middleware('checkLogin');
    //导出
    Route::group('Error', function () use ($version) {
        //学习记录导出
        Route::get('exportExcel', "api/{$version}.Error/exportExcel");
        //考试错题导出
        Route::get('errorsExcel', "api/{$version}.Error/errorsExcel");
    })->middleware('checkLogin');

})->allowCrossDomain([
    'Access-Control-Allow-Origin' => '*',
    'Access-Control-Allow-Methods' => 'GET,POST',
    'Access-Control-Allow-Headers' => 'content-type,token,version',
    'Access-Control-Allow-Credentials' => 'true'
]);